package com.example.design.demo.clone;

/**
 * @author lfj
 * @date 2023/11/24 17:23
 * @description 原型模式的注意事项
 */
public class PrototypeClass03 implements Cloneable {

    private String id;

    private String name;

    private TestPrototype testPrototype;


    @Override
    public PrototypeClass03 clone() {
        PrototypeClass03 thing=null;
        try {
            thing = (PrototypeClass03)super.clone();
            thing.setTestPrototype((TestPrototype) testPrototype.clone());
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return thing;
    }


    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public TestPrototype getTestPrototype() {
        return testPrototype;
    }

    public void setTestPrototype(TestPrototype testPrototype) {
        this.testPrototype = testPrototype;
    }
}
